function checkLocationForBom(seq) {

	var cnt = document.bomPartEntryForm.count.value;

	if ( parseInt ( cnt ) != 1 )
	{
		str = eval('document.bomPartEntryForm.select['+seq+'].checked');
	}
	else
	{
		str = eval('document.bomPartEntryForm.select.checked');
	}
	var maxVal = 0;

	if(cnt!=1)
	{
		if(str==false)
		{
			document.bomPartEntryForm.priority[seq].disabled=false;
			// added to set the default priority by ravikanth
			maxVal =  document.bomPartEntryForm.priority[seq].value;
			for ( var y =0 ; y < cnt ; y++ )
			{
				temp   = parseInt ( document.bomPartEntryForm.priority[y].value );
				if( temp > maxVal && maxVal != 0)
				{
					document.bomPartEntryForm.priority[y].value = parseInt(document.bomPartEntryForm.priority[y].value) -1;
					document.bomPartEntryForm.priority[y].disabled = true;
				}
			}
			document.bomPartEntryForm.priority[seq].disabled=false;
			document.bomPartEntryForm.priority[seq].value='';
			document.bomPartEntryForm.priority[seq].disabled = true;
		}
		if(str==true)
		{
			document.bomPartEntryForm.priority[seq].disabled=false;
			for ( var y =0 ; y < cnt ; y++ )
			{
				temp   = parseInt ( document.bomPartEntryForm.priority[y].value );
				if( temp > maxVal)
				{
					maxVal = temp
				}
				document.bomPartEntryForm.priority[y].disabled = true;
			}
			document.bomPartEntryForm.priority[seq].value= parseInt(maxVal)+1 ;
			document.bomPartEntryForm.priority[seq].disabled = true;
		}
	}
	else
	{
		if(str==false)
		{
			document.bomPartEntryForm.priority.disabled=true;
			document.bomPartEntryForm.priority.value= '';
		}
		if(str==true)
		{
			document.bomPartEntryForm.priority.value= 1;
			document.bomPartEntryForm.priority.diabled = true;
		}
   }
}



function checkValuesForBoardMaking()
{
    var cnt = document.bomPartEntryForm.count.value;
    var pa  = document.getElementById("errors");
    if(cnt==1)
    {
		str = eval('document.bomPartEntryForm.select.checked');

		if(str==true)
		{
			document.bomPartEntryForm.priority.value = document.bomPartEntryForm.priority.value.trim();
			var priority = document.bomPartEntryForm.priority.value;
			if ( priority.length != '' )
			{
				//if ( checkInteger ( priority.trim(), 'Priority', 'Y' ) == false )
				if ( isInteger ( priority ) == false )
				{
					pa.innerHTML = "Please enter valid Priority, It must be number";
					document.bomPartEntryForm.priority.select();
					document.bomPartEntryForm.priority.focus();
					return false;
				}
			}
			else
			{
				pa.innerHTML = "Please enter Priority, It must be number";
				document.bomPartEntryForm.priority[i].select();
				document.bomPartEntryForm.priority[i].focus();
				return false;
			}
		}
	}

    else
    {
		var selects = document.bomPartEntryForm["select"];
        for(var i=0;i<cnt;i++)
		{
			str = selects[i].checked;
			if(str==true)
			{
				document.bomPartEntryForm.priority[i].value = document.bomPartEntryForm.priority[i].value.trim();
				var priority = document.bomPartEntryForm.priority[i].value;
				if ( priority.length != '' )
				{
					//if ( checkInteger ( priority.trim(), 'Priority', 'Y' ) == false )
					if ( isInteger ( priority ) == false )
					{
						pa.innerHTML = "Please enter valid Priority, It must be number";
						document.bomPartEntryForm.priority[i].select();
						document.bomPartEntryForm.priority[i].focus();
						return false;
					}
					for ( var jj = i+1; jj < cnt ; jj++)
					{
						if ( priority == document.bomPartEntryForm.priority[jj].value.trim() )
						{
							pa.innerHTML = "Please enter a different Priority Number";
							return false;
						}
					}
				}
				else
				{
					pa.innerHTML = "Please enter Priority, Blank values are not permitted";
					document.bomPartEntryForm.priority[i].select();
					document.bomPartEntryForm.priority[i].focus();
					return false;
				}
			}
		}
    }

    if(cnt!=1)
	{
		for(var i=0;i<cnt;i++)
		{
			document.bomPartEntryForm.priority[i].disabled=false;
			document.bomPartEntryForm.locationName[i].disabled=false;
		}
    }
    else
    {
		document.bomPartEntryForm.priority.disabled=false;
		document.bomPartEntryForm.locationName.disabled=false;
    }
    return true;
}


function vendorValidations(form)
{
	var pa	= document.getElementById("errors");
	var num = form.priority.length;
	var retVal = false;
	if ( form.priority.length == null )
	{
		var singleVendor = eval("form.select");
		if ( ( singleVendor.checked == true ) && ( form.priority.value.length > 0) )
		{
			retVal = true;
		}
	}
	for ( var len = 0; len < num; len++)
	{
		var temp = eval ("form.select["+len+"]");
		if ( ( temp.checked == true ) && ( form.priority[len].value.length > 0 ) )
		{
			retVal = true;
		}
	}
	return retVal
}

